#!/usr/bin/php
<?php

  //ini_set("memory_limit","300M");

$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__).'/collections'), RecursiveIteratorIterator::CHILD_FIRST);

foreach($iterator as $it){
      if($it->isFile()) print $it."\n";
      if($it->isFile() && strpos($it, '.jpeg') &&
	 !strpos($it, '_low.jpeg') && !strpos($it, '_high.jpeg')){
	// echo $it;
	// $jpg = imagecreatefromjpeg($it);
	// $lowResName = preg_replace('/.jpeg/', '_low.jpeg', $it);
	// $highResName = preg_replace('/.jpeg/', '_high.jpeg', $it);
	// $compression = 75;
	// $resizePercentage = 25;
	// $oldWidth = imagesx($jpg);
	// $width = $oldWidth * $resizePercentage/100;
	// $oldHeight = imagesy($jpg);
	// $height = $oldHeight * $resizePercentage/100;
	// $newImage = imagecreatetruecolor($width, $height);
	// imagecopyresampled($newImage, $jpg, 0, 0, 0, 0,
	// 		   $width, $height, $oldWidth, $oldHeight);
	// imagejpeg($newImage, $lowResName, $compression);
	// imagedestroy($newImage);
	// imagedestroy($jpg);
	// rename($it, $highResName);
      }
}
?>